const Buff = require('./buff');

const {game: gameConfig} = require('./config');

class Item {
    constructor(game, type, strong) {
        this.game = game;
        this.type = type;
        this.strong = strong;
    }
    endue(runner) {

    }
    static violent(game, strong) {
        return new BuffItem(game, Buff.types.violent, strong);
    }
    static vertigo(game, strong) {
        return new BuffItem(game, Buff.types.vertigo, strong);
    }
    static forward(game, strong) {
        return new ForwardItem(game, 'forward', strong);
    }

    static random(game) {
        let type = Math.floor(Math.random() * 2)
        switch (type) {
            case 0: return Item.violent(game, gameConfig.item.violent);
            case 1: return Item.vertigo(game, gameConfig.item.vertigo);
            // case 2: return Item.forward(game, 1);
        }
    }
}

class BuffItem extends Item {
    constructor(game, type, strong) {
        super(game, type, strong);
    }
    endue(runner) {
        this.game.buff(runner, this.type, this.strong);
    }
}

class ForwardItem extends Item {
    constructor(game, type, strong) {
        super(game, type, strong);
    }
    endue(runner) {
        this.game.forward(runner, this.strong);
    }
}

module.exports = Item;
